# -*- coding: utf-8 -*-

import os
from config import PROJECT_FOLDER, PROJECT_NAME


def get_working_folder():
    """获取工作目录, 统一目录管理. 
    """
    if os.name == 'nt':
        working_folder = u"d:\\"
    else:
        working_folder = u"/data/appdatas"
    working_folder = os.path.join(working_folder, "%s_working_folder" % PROJECT_NAME)
    if not os.path.exists(working_folder):
        try:
            os.makedirs(working_folder)
        except OSError as e:
            if e.args[0] == 17:
                pass
            else:
                raise
    return working_folder


class PathConfig(object):
    PROJECT_FOLDER = PROJECT_FOLDER
    WORKING_FOLDER = get_working_folder()  # 工作根目录
    LOG_ROOT = os.path.join(WORKING_FOLDER, "event_log")  # 日志目录
    EXCEPTION = os.path.join(WORKING_FOLDER, "exception")  # 异常日志目录
    FILE_LOCKER = os.path.join(WORKING_FOLDER, "file_locker")  # 文件锁目录
